package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointMerchantStock;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Carrot Point 가맹점(입점업체) 상품 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointMerchantStockDaoImpl extends SqlSessionDaoSupport implements CarrotPointMerchantStockDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointMerchantStockDaoImpl.class);

    /**
     * 가맹점(입점업체) 상품을 등록 한다.
     *
     * @param carrotPointMerchantStock
     */
    @Override
    public void registerMerchantStock(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("registerMerchantStock");
        this.getSqlSession().insert("CARROTPOINT_MERCHANT_STOCK.registerMerchantStock", carrotPointMerchantStock);
    }

    /**
     * 가맹점(입점업체) 상품 목록을 가져 온다.
     *
     * @param carrotPointMerchantStock
     * @return
     */
    @Override
    public List<CarrotPointMerchantStock> getMerchantStockList(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("getMerchantStockList");
        return this.getSqlSession().selectList("CARROTPOINT_MERCHANT_STOCK.getMerchantStockList", carrotPointMerchantStock);
    }

    /**
     * 모든 가맹점(입점업체) 전체 상품 목록을 가져 온다.
     *
     * @param carrotPointMerchantStock
     * @return
     */
    @Override
    public List<CarrotPointMerchantStock> getTotalMerchantStockList(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("getTotalMerchantStockList");
        return this.getSqlSession().selectList("CARROTPOINT_MERCHANT_STOCK.getTotalMerchantStockList", carrotPointMerchantStock);
    }

    /**
     * 가맹점(입점업체) 상품 내용을 가져 온다.
     *
     * @param carrotPointMerchantStock
     * @return
     */
    @Override
    public CarrotPointMerchantStock getMerchantStockInformation(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("getMerchantStockInformation");
        return (CarrotPointMerchantStock)getSqlSession().selectOne("CARROTPOINT_MERCHANT_STOCK.getMerchantStockInformation", carrotPointMerchantStock);
    }

    /**
     * 가맹점(입점업체) 상품 내용을 수정 한다.
     *
     * @param carrotPointMerchantStock
     */
    @Override
    public void updateMerchantStockInformation(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("updateMerchantStockInformation");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_STOCK.updateMerchantStockInformation", carrotPointMerchantStock);
    }

    /**
     * 가맹점(입점업체) 상품을 비활성화 한다.
     *
     * @param carrotPointMerchantStock
     */
    @Override
    public void updateDeactivateMerchantStock(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("updateDeactivateMerchantStock");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_STOCK.updateDeactivateMerchantStock", carrotPointMerchantStock);
    }

    /**
     * 모든 가맹점(입점업체) 상품 검색 목록을 가져 온다.
     *
     * @param carrotPointMerchantStock
     * @return
     */
    @Override
    public List<CarrotPointMerchantStock> getSearchMerchantStockList(CarrotPointMerchantStock carrotPointMerchantStock) {
        logger.info("getSearchMerchantStockList");
        return this.getSqlSession().selectList("CARROTPOINT_MERCHANT_STOCK.getSearchMerchantStockList", carrotPointMerchantStock);
    }
}
